﻿@using Kevin.Shop.Business.Service.Entity.Helper
@{
    Layout = "../Shared/_MobileLayout.cshtml";
}
@section title
{
    我的评价
}
@section pagetitle
{
    我的评价
}
@section header
{
    <link href="~/Themes/RongJi/Style/base/css/myaccount.css" rel="stylesheet">
}
<div class="userCenterHeader">
    <span class="iconWrapper">
        <img src="~/Themes/RongJi/Style/base/imgs/icon_ping.png">
    </span>
    <h3>
        <select id="reviewStatus" style="font-size:70%;min-width:80px;">
            @if (Request.QueryString["status"] == "1")
            {
                <option value="0">待评价</option>
                <option value="1" selected>全部</option>
            }
            else
            {
                <option value="0" selected>待评价</option>
                <option value="1">全部</option>
            }
        </select>
    </h3>
    <br class="clearfix">
</div>
@model RiderShop.Mobile.Modle.MyAccount.MyCommentModel
@if (Model.CommentList == null)
{
    <div class="box">
        <div id="empty" style="text-align: center">
            <p>@Html.Raw("暂无评价")</p>
            <div class="btn btn-default">
                <a href="/Home" class="empty_go_main">去逛逛</a>
            </div>
        </div>
    </div>
}
else
{
    <div class="box">
        <div id="myCommentList">
            @foreach (var item in Model.CommentList)
            {
                <div class="ItemTable ItemFavorite">
                    <div class="ItemLeft">
                        <a href="~/Product/ProductDetail?prd=@item.ProductId">
                            <img src="@RiderShop.Mobile.Common.Component.SiteUrl.FormatProductImageUrl(Kevin.Shop.Business.Service.Entity.Products.Enumerations.ImageType.Size125, item.ProductId, item.ImageName)">
                        </a>
                    </div>
                    <div class="ItemRight ItemRightWrod">
                        <p class="title">商品名称：<a href="~/Product/ProductDetail?prd=@item.ProductId">@item.ProductName</a></p>
                        <p class="gray">商品编号：@item.ProductId</p>
                        <p class="gray">订单编号：@item.OrderNumber</p>
                        <p class="gray">购买日期：@item.InDate</p>
                        <p class="gray">购买价格：@item.UnitPrice</p>
                    </div>
                    <div class="linkToComment">
                        @if (string.IsNullOrEmpty(item.PresentPointDisplay))
                        {
                            <a pid="=@item.ProductId" href="~/MyAccount/PublishComment?prd=@item.ProductId&orderNumber=@item.OrderNumber" class="btn btn-warning">评价</a>
                        }
                        else
                        {
                            <a pid="@item.ProductId" class="btn btn-success" data-toggle="modal" data-target="@Html.Raw("#p" + @item.OrderNumber+'_' + @item.ProductId)">查看评价</a>
                            <div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true" id="@Html.Raw("p" + @item.OrderNumber+'_' + @item.ProductId)">
                                <div class="modal-dialog modal-lg" id="@Html.Raw("m" + @item.OrderNumber+'_' + @item.ProductId)">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                            <h4 class="modal-title" id="myLargeModalLabel">评价信息</h4>
                                        </div>
                                        <div class="modal-body">
                                            <div class="star-line">
                                                <label class="@Html.Raw("re" + @item.Rating)" id="lblRatingLevel">
                                                    <ul>
                                                        <li></li>
                                                        <li></li>
                                                        <li></li>
                                                        <li></li>
                                                        <li></li>
                                                    </ul>
                                                    <span class="retext">
                                                        @if (@item.Rating == 1)
                                                        {
                                                            @Html.Raw("非常差");
                                                        }
                                                        else if (@item.Rating == 2)
                                                        {
                                                            @Html.Raw("比较差");
                                                        }
                                                        else if (@item.Rating == 3)
                                                        {
                                                            @Html.Raw("一般");
                                                        }
                                                        else if (@item.Rating == 4)
                                                        {
                                                            @Html.Raw("比较好");
                                                        }
                                                        else if (@item.Rating == 5)
                                                        {
                                                            @Html.Raw("很好");
                                                        }
                                                    </span>
                                                </label>
                                            </div>
                                            <div class="commentview">
                                                标题：@item.Title<br />
                                                @*优点：@item.MeritText<br />
                                                不足：@item.FaultsText<br />*@
                                                描述：@item.Memo
                                            </div>
                                            @if (!string.IsNullOrWhiteSpace(item.Images))
                                            {
                                                var images = item.Images.Split(',');
                                                <div class="clearfix">
                                                    <ul id="reviewImageList" class="clearfix">
                                                        @foreach (var imageName in images)
                                                        {
                                                            if (string.IsNullOrWhiteSpace(imageName))
                                                            {
                                                                continue;
                                                            }
                                                            <li>
                                                                <div style="background:url(@(WebClientContext.Current.FileServerDomain+imageName+"?imageView2/0/w/150")) no-repeat center center; background-size:contain;">
                                                                    
                                                                </div>
                                                            </li>
                                                        }
                                                    </ul>
                                                </div>
                                            }
                                        </div>
                                    </div>
                                </div>
                            </div>
                        }
                    </div>
                </div>
            }
        </div>
        <div class="ItemTable" id="showMore" page="1">
            更多...
        </div>
    </div>
}

@section footer
{
    <script language="javascript" type="text/javascript">
        $(function() {
            $('#divWindow').hide();
            //让底部toolbar选中
            var $homeImg = $("#homeImg");
            var $categoryImg = $("#categoryImg");
            var $myaccountImg = $("#myaccountImg");
            var $searchImg = $("#searchImg");
            $homeImg.attr("src", "/Themes/RongJi/Style/base/imgs/f10.png");
            $categoryImg.attr("src", "/Themes/RongJi/Style/base/imgs/f2.png");
            $myaccountImg.attr("src", "/Themes/RongJi/Style/base/imgs/f3_c.png");
            $searchImg.attr("src", "/Themes/RongJi/Style/base/imgs/f4.png");

            $("#reviewStatus").change(function(){
                window.location.href="MyComment?status="+$(this).val();
            });

            //当只有一页数据时'更多'不需要显示出来
            if(@Model.TotalPage == 1) {
                $("#showMore").hide();
            }

            //滚动到屏幕底部时,追加下一页数据
            /*---------------------加载更多--------------------*/
            var isloading = false;
            var counter = 1;
            var totalPage = @Model.TotalPage;
            if(totalPage > 1) {
                $(window).bind("scroll", function() {
                    if ($(document).scrollTop() + $(window).height() >= $(document).height()) {
                        var pageIndex = $('#showMore').attr('page');
                        $('#showMore').show().html('正在加载中...');
                        if(pageIndex >= totalPage) {
                            $("#showMore").show().html('加载完毕').delay(2300).slideUp(1600);
                            return;
                        }
                        if(isloading) {
                            return;
                        }
                        isloading = true;
                        $.ajax({
                            type: "GET",
                            url:  "MyCommentAjaxRequest?pageIndex=" + pageIndex,
                            success: function(response){
                                isloading = false;
                                $('#showMore').attr('page',parseInt(pageIndex)+1);
                                $("#myCommentList").append("<div id='div" + counter + "' style='margin-top:100px;opacity:0.3'></div>");
                                $("#div" + counter).append(response).animate({ opacity: '1', marginTop: 0 }, 2000);
                                counter++;
                            },
                            error:function(err){
                                alert(err.responseText);
                            }
                        });
                    }
                });
            }
        });
    </script>
}